package com.zdp.test.proxy.jdkproxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * @describte:Jdk动态代理增强逻辑
 * @program:ThoughtTest
 * @author:zhengdp
 * @create:2021-12-25 20:52:35
 **/
public class JdkProxyInvocation implements InvocationHandler {

    // 被代理对象
    private Object target;

    public JdkProxyInvocation(Object target){
        this.target = target;
    }

    /**
     *
     * @param proxy 代理对象
     * @param method 当前方法
     * @param args 方法参数
     * @return
     * @throws Throwable
     */
    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.out.println("Jdk动态代理增强逻辑1");
        Object result = method.invoke(target,args);
        System.out.println("Jdk动态代理增强逻辑2");
        return result;
    }
}
